<?php
/**
 * Created by PhpStorm.
 * User: hjl
 * Date: 2016/8/31
 * Time: 14:01
 */

namespace Admin\Controller;

/**
 * Class 地图显示
 * @package Admin\Controller
 */
class MapController extends BaseController
{

    public function index()
    {
        $this->display();
    }
//
//{
//"status": 401,
//"message": "此账户不存在或token有误",
//"time": 1474200560,
//"content": [
//{
//"title": "百恒网络",
//"content": "电话：0791-88117053 手机：15079002975",
//"isOpen": "1",
//"point": "115.950312|28.693447"
//}
//]
//}

    public function getPosition()
    {
        $result = D("gas_station")->select();
        if ($result != null) {
            $station_length = count($result);

            for ($index = 0; $index < $station_length; $index++) {

                if(empty($result[$index]["addr_lon"])|| empty($result[$index]["addr_lat"])){
                    continue;
                }
                $location["title"] = $result[$index]["name"];
                $location["owner_name"] = $result[$index]["owner_name"];
                $location["addr"] = $result[$index]["addr"];

                $location_info = $result[$index]["addr_lon"] . "|" . $result[$index]["addr_lat"];
                $location["point"] = $location_info;
                $data[$index] = $location;
            }
            $this->apiReturn(200, '找到油站信息', $data, ApiReturn);
        } else {
            $this->apiReturn(400, '未找到油站信息', null, ApiReturn);
        }
    }
}